package com.ruoyi.project.jiaqin.subject.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.jiaqin.subject.domain.JiaqinSubject;
import com.ruoyi.project.jiaqin.subject.mapper.JiaqinSubjectMapper;
import com.ruoyi.project.jiaqin.subject.service.IJiaqinSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 话题Service业务层处理
 *
 * @author admin
 * @date 2020-12-30
 */
@Service
public class JiaqinSubjectServiceImpl implements IJiaqinSubjectService
{
    @Autowired
    private JiaqinSubjectMapper jiaqinSubjectMapper;

    /**
     * 查询话题
     *
     * @param id 话题ID
     * @return 话题
     */
    @Override
    public JiaqinSubject selectJiaqinSubjectById(String id)
    {
        return jiaqinSubjectMapper.selectJiaqinSubjectById(id);
    }

    /**
     * 查询话题列表
     *
     * @param jiaqinSubject 话题
     * @return 话题
     */
    @Override
    public List<JiaqinSubject> selectJiaqinSubjectList(JiaqinSubject jiaqinSubject)
    {
        return jiaqinSubjectMapper.selectJiaqinSubjectList(jiaqinSubject);
    }

    @Override
    public PageInfo<JiaqinSubject> getSubjectByIndId(Integer pageNum, Integer pageSize, String industryId) {
        PageHelper.startPage(pageNum,pageSize);
        List<JiaqinSubject> list = jiaqinSubjectMapper.getSubjectByIndId(industryId);
        PageInfo<JiaqinSubject> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 新增话题
     *
     * @param jiaqinSubject 话题
     * @return 结果
     */
    @Override
    public int insertJiaqinSubject(JiaqinSubject jiaqinSubject)
    {
        jiaqinSubject.setId(UUID.randomUUID().toString().replace("-",""));
        jiaqinSubject.setCreateAt(new Date());
        return jiaqinSubjectMapper.insertJiaqinSubject(jiaqinSubject);
    }

    /**
     * 修改话题
     *
     * @param jiaqinSubject 话题
     * @return 结果
     */
    @Override
    public int updateJiaqinSubject(JiaqinSubject jiaqinSubject)
    {
        return jiaqinSubjectMapper.updateJiaqinSubject(jiaqinSubject);
    }

    /**
     * 删除话题对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteJiaqinSubjectByIds(String ids)
    {
        return jiaqinSubjectMapper.deleteJiaqinSubjectByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除话题信息
     *
     * @param id 话题ID
     * @return 结果
     */
    @Override
    public int deleteJiaqinSubjectById(String id)
    {
        return jiaqinSubjectMapper.deleteJiaqinSubjectById(id);
    }
}
